import configSetting from '@/config'
import ReactUeditor from 'ifanrx-react-ueditor-fix'
import React, { Component } from 'react'


const ReactUeditorPath = configSetting.ReactUeditorPath

export default class AntdUeditor extends Component {

  uploadImage = e => {
    return new Promise(function(resolve, reject) {
      resolve(window.URL.createObjectURL(e.target.files[0]))
    })
  }

  handlePasteImage = src => {
    return new Promise(function(resolve) {
      setTimeout(() => {
        resolve('https://s3.ifanr.com/wp-content/uploads/2019/01/WechatIMG974.jpeg!720')
      }, 1000)
    })
  }

  render () {
    const { uploadImage, handlePasteImage } = this;
    const { value = '' } = this.props;
    return (
      <ReactUeditor
        config={{initialFrameHeight:620,initialFrameWidth:470}}
        ueditorPath={ReactUeditorPath}
        handlePasteImage={handlePasteImage}
        uploadImage={uploadImage}
        plugins={[
          'insertCode',
          'uploadImage',
          'uploadVideo',
          'uploadAudio',
          'insertLink',
        ]}
        value = {value}
      />
    )

  }
}